﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Checkname.aspx.cs" Inherits="CheckNameProject.Checkname" %>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <style type="text/css">
        .style2
        {
            width: 372px;
        }
        .style4
        {
            width: 72px;
        }
        .style9
        {
            width: 224px;
        }
    </style>
    
    </asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    
    <script type="text/javascript">
    function Confirm() {
    var confirm_value = document.createElement("INPUT");
    confirm_value.type = "hidden";
    confirm_value.name = "confirm_value";
    if (confirm("บุคลากรท่านนี้ไม่มีอยู่ในข้อมูล ต้องการที่จะเพิ่มหรือไม่?")) {
    confirm_value.value = "Yes";
    } else {
    confirm_value.value = "No";
    }
        document.getElementById('hfData').value = confirm_value.value;
    }
    </script>

     
    <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
    </asp:ToolkitScriptManager>
    
    <asp:SqlDataSource ID="SqlPos" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ApplicationServices %>" 
        SelectCommand="SELECT * FROM [Position]"></asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlPerson" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ApplicationServices %>" 
        SelectCommand="SELECT Person.PersonID, Person.FirstName, Person.LastName, Status.DocumentID, Status.Status, Status.CauseID, Status.PersonID AS Expr1 FROM Person INNER JOIN Status ON Person.PersonID = Status.PersonID WHERE (Status.DocumentID = @DocumentID)">
        <SelectParameters>
            <asp:QueryStringParameter DefaultValue="0" Name="DocumentID" 
                QueryStringField="ID" />
        </SelectParameters>
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlCause" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ApplicationServices %>" 
        SelectCommand="SELECT * FROM [Cause]"></asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlNameList" runat="server"></asp:SqlDataSource>
    <h1>คำสั่ง : 
        <asp:LinkButton ID="lbtnDocName" runat="server" onclick="lbtnDocName_Click">LinkButton</asp:LinkButton>
&nbsp;</h1>
    <p>
        <asp:Label ID="lblStatus" runat="server" Text="Label"></asp:Label>
    </p>
   
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
        CellPadding="4" ForeColor="#333333" GridLines="None" Width="913px" 
        DataSourceID="SqlPerson" AllowPaging="True" 
        onrowdeleting="GridView1_RowDeleting" 
        onrowdatabound="GridView1_RowDataBound">
        <AlternatingRowStyle BackColor="White" />
        <Columns>
            <asp:TemplateField HeaderText="ชื่อ - นามสกุล">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Eval("FirstName") %>'></asp:Label>
                    &nbsp;
                    <asp:Label ID="Label2" runat="server" Text='<%# Eval("LastName") %>'></asp:Label>
                    <asp:HiddenField ID="HiddenField1" runat="server" 
                        Value='<%# Eval("PersonID") %>' />
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="เข้าร่วม">
                <ItemTemplate>
                    <asp:CheckBox ID="chkJoin" runat="server" Checked='<%# Bind("Status") %>' />
                </ItemTemplate>
                <ItemStyle HorizontalAlign="Center" />
            </asp:TemplateField>
            <asp:TemplateField HeaderText="สาเหตุการขาดประชุม">
                <ItemTemplate>
                    <asp:DropDownList ID="cbCause" runat="server" Height="20px" Width="145px" 
                        DataSourceID="SqlCause" DataTextField="Cause" DataValueField="CauseID">
                    </asp:DropDownList>
                </ItemTemplate>
                <ItemStyle HorizontalAlign="Center" />
            </asp:TemplateField>
            <asp:TemplateField ShowHeader="False">
                <ItemTemplate>
                    <asp:ImageButton ID="ImageButton1" runat="server" CausesValidation="False" 
                        CommandName="Delete" ImageUrl="~/Image/delete_icon.gif" Text="Delete" />
                </ItemTemplate>
                <HeaderStyle HorizontalAlign="Right" />
                <ItemStyle HorizontalAlign="Right" />
            </asp:TemplateField>
        </Columns>
        <EditRowStyle BackColor="#2461BF" />
        <EmptyDataTemplate>
            <asp:Panel ID="Panel1" runat="server" HorizontalAlign="Center" 
                BackColor="#FFFF66">
                <asp:Label ID="Label3" runat="server" Font-Bold="True" Font-Size="Medium" 
                    ForeColor="Red" 
                    Text="ยังไม่มีบุคลากรภายในคำสั่งนี้  กรุณาเพิ่มรายชื่อบุคลากรด้วยค่ะ"></asp:Label>
            </asp:Panel>
        </EmptyDataTemplate>
        <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
        <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
        <PagerSettings Mode="NextPreviousFirstLast" />
        <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
        <RowStyle BackColor="#EFF3FB" />
        <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
        <SortedAscendingCellStyle BackColor="#F5F7FB" />
        <SortedAscendingHeaderStyle BackColor="#6D95E1" />
        <SortedDescendingCellStyle BackColor="#E9EBEF" />
        <SortedDescendingHeaderStyle BackColor="#4870BE" />
    </asp:GridView>
    
    <br />
    <table style="width:100%;">
        <tr>
            <td align="right">
                <asp:Button ID="btnSave" runat="server" Text="บันทึก" onclick="btnSave_Click" 
                    Visible="False" />
            </td>
        </tr>
    </table>
    
    <br />
    <asp:TabContainer ID="TabContainer1" runat="server" ActiveTabIndex="0" 
        Width="100%" EnableTheming="True" ScrollBars="Auto" Height="108px">
        <asp:TabPanel runat="server" HeaderText="TabPanel1" ID="TabPanel1">
            <HeaderTemplate>ค้นหารายชื่ออาจารย์/บุคลากร</HeaderTemplate>
            <ContentTemplate><asp:Panel ID="panSearch" runat="server"><table style="width:100%;"><tr><td class="style2">ชื่อ : <asp:TextBox ID="txtPersonName" runat="server" Width="326px"></asp:TextBox><asp:AutoCompleteExtender ID="txtPersonName_AutoCompleteExtender" 
                                    runat="server" DelimiterCharacters="" Enabled="True" 
                                    ServiceMethod="GetCompletionList" TargetControlID="txtPersonName" 
                                    UseContextKey="True" ServicePath=""></asp:AutoCompleteExtender>
                <asp:RequiredFieldValidator ID="NReq" runat="server" 
                                    ControlToValidate="txtPersonName" Display="None" 
                                    
                    ErrorMessage="&lt;b&gt;กรุณาใสข้อมูล&lt;/b&gt;&lt;br /&gt;กรุณาใส่ชื่อและนามสกุลของผู้ที่ต้องการค้นหา" 
                    ValidationGroup="DocSearch"></asp:RequiredFieldValidator><asp:ValidatorCalloutExtender ID="ValidatorCalloutExtender1" runat="server" 
                                     Enabled="True" 
                                    PopupPosition="BottomLeft" TargetControlID="NReq"></asp:ValidatorCalloutExtender></td><td>
                    <asp:Button ID="btnConfirm" runat="server" onclick="btnConfirm_Click" 
                                    Text="ตกลง" Width="80px" ValidationGroup="DocSearch" /></td></tr></table></asp:Panel></ContentTemplate>
        </asp:TabPanel>
        <asp:TabPanel ID="TabPanel2" runat="server" HeaderText="TabPanel2">
            <HeaderTemplate>เพิ่มรายชื่ออาจารย์/บุคลากร</HeaderTemplate>
            <ContentTemplate><asp:Panel ID="panInsert" runat="server"><table style="width:100%;"><tr><td class="style4">
                ชื่อจริง</td><td class="style1"><asp:TextBox ID="txtFirstname" runat="server" Width="214px"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="NReqAdd" runat="server" 
                        ControlToValidate="txtFirstname" Display="None" 
                        ErrorMessage="&lt;b&gt;กรุณาใสข้อมูล&lt;/b&gt;&lt;br /&gt;กรุณาใส่ชื่อ" 
                        ValidationGroup="AddName"></asp:RequiredFieldValidator>
                    <asp:ValidatorCalloutExtender ID="NReqAdd_ValidatorCalloutExtender" 
                        runat="server" PopupPosition="TopLeft" TargetControlID="NReqAdd">
                    </asp:ValidatorCalloutExtender>
                </td><td class="style4">นามสกุล</td><td class="style9"><asp:TextBox ID="txtLastname" runat="server" Width="214px"></asp:TextBox></td><td>
                <asp:RequiredFieldValidator ID="SNReqAdd" runat="server" 
                    ControlToValidate="txtLastname" Display="None" 
                    ErrorMessage="&lt;b&gt;กรุณาใสข้อมูล&lt;/b&gt;&lt;br /&gt;กรุณาใส่นามสกุล" 
                    ValidationGroup="AddName"></asp:RequiredFieldValidator>
                <asp:ValidatorCalloutExtender ID="SNReqAdd_ValidatorCalloutExtender" 
                    runat="server" PopupPosition="TopLeft" TargetControlID="SNReqAdd">
                </asp:ValidatorCalloutExtender>
                </td></tr><tr><td class="style4">คณะ</td><td class="style1"><asp:DropDownList ID="cbFact" runat="server" AutoPostBack="True" 
                                    DataSourceID="SqlFact" DataTextField="Faculty" DataValueField="FacultyID" 
                                    Height="22px" Width="218px"></asp:DropDownList><asp:SqlDataSource ID="SqlFact" runat="server" 
                                    ConnectionString="<%$ ConnectionStrings:ApplicationServices %>" 
                                    SelectCommand="SELECT * FROM [Faculty]"></asp:SqlDataSource></td><td class="style4">
                        ภาควิชา</td><td class="style9"><asp:UpdatePanel ID="UpdatePanel1" runat="server"><ContentTemplate><asp:DropDownList ID="cbDep" runat="server" DataSourceID="SqlDept" 
                                            DataTextField="Department" DataValueField="DepartmentID" Height="22px" 
                                            Width="218px"></asp:DropDownList></ContentTemplate><Triggers><asp:AsyncPostBackTrigger ControlID="cbFact" EventName="SelectedIndexChanged" /></Triggers></asp:UpdatePanel><asp:SqlDataSource ID="SqlDept" runat="server" 
                                    ConnectionString="<%$ ConnectionStrings:ApplicationServices %>" 
                                    SelectCommand="SELECT * FROM [Department] WHERE ([FacultyID] = @FacultyID)"><SelectParameters><asp:ControlParameter ControlID="cbFact" DefaultValue="0" Name="FacultyID" 
                                            PropertyName="SelectedValue" Type="Int32" /></SelectParameters></asp:SqlDataSource></td><td>
                        &nbsp;</td></tr><tr><td class="style4">ตำแหน่ง</td><td class="style1"><asp:DropDownList ID="cbPos" runat="server" 
                                    DataSourceID="SqlPos" DataTextField="Position" DataValueField="PositionID" 
                                    Height="22px" Width="218px"></asp:DropDownList></td><td class="style4">
                        &nbsp;</td><td class="style9">&nbsp;</td><td>&nbsp;</td></tr><tr><td class="style4">&nbsp;</td><td class="style1">
                &nbsp;&nbsp;</td><td class="style4">&nbsp;</td><td align="right" class="style9">
                <asp:Button ID="btnAdd" runat="server" OnClick="btnAdd_Click" Text="เพิ่ม" 
                                    Width="63px" ValidationGroup="AddName" /></td><td>&nbsp;</td></tr></table></asp:Panel></ContentTemplate>
        </asp:TabPanel>
        <asp:TabPanel ID="TabPanel3" runat="server" HeaderText="TabPanel3">
            <HeaderTemplate>อัพโหลดไฟล์เอกสารคำสั่ง</HeaderTemplate>
        <ContentTemplate>
            <asp:Panel ID="panFile" runat="server" Visible="False">
                <asp:Label ID="lblFile" runat="server"></asp:Label>
                <asp:Button ID="btnDeleteFile" runat="server" onclick="btnDeleteFile_Click" 
                    Text="ลบไฟล์" />
            </asp:Panel>
            <asp:FileUpload ID="FileUploadControl" runat="server" Width="400px" />
            <asp:Button ID="btnUpload" runat="server" onclick="btnUpload_Click" 
                Text="อัพโหลดไฟล์" />
            <br />
            <asp:Label ID="lblStatUpload" runat="server"></asp:Label>
            </ContentTemplate></asp:TabPanel>
    </asp:TabContainer>
    <br />
    <br />
    <br />
</asp:Content>
